﻿<html> 
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15"/>
<title>Web剪刀手</title>
<link rel="stylesheet" type="text/css" href="options.css"/>
<link rel="shortcut icon" href="logo_32.png" type="image/x-icon" /> 
<style type='text/css'>

</style>
<script type="text/javascript" src="newwords.js"></script>
<script type="text/javascript" src="jquery-1.4.js"></script>
<script type="text/javascript" src="remember.js"></script>
<script type="text/javascript" src="http://webscissor.appspot.com/static/YX_Base.js"></script>
<script> 
var currentpage = 0;
var PAGE_SIZE=7;

//从URL里提取用户ID和item ID。
//URL 格式：http://webscissor.appspot.com/use_id/
function GetUrlUserID(strRet)
{
    //return /code=(\d*)/.exec(strRet)[1];
    var res = /http:\/\/webscissor.appspot.com\/(\d*)\//.exec(strRet);
    return {user_id:res[1]};
}
alert(GetUrlUserID("http://webscissor.appspot.com/123/456/").user_id);

function ShowList()
{
    yxBase.GetList(0,
        -1,
        function (listData)
        {
            for(var i=0;i<listData.length;i++)
            {
                var gid  = listData[i][0];
                yxBase.GetData(gid,function (res){
                    var gid  = res[0];
                    var gver = res[1];
                    var del  = res[2];
                    var item = JSON.parse(res[3]);
                    var title = item[1];
                    var body = item[2];
                    var pageUrl = item[3];
                    var addTime = new Date(item[4]);
                    getid("div_data").innerHTML += "<H1>" + title + "</H1><pre>" + body + "</pre>";
                });
            }
        },
        function (error)
        {
            getid("div_data").innerHTML = "读取数据失败：" + error ;
        }
    );
}

var yxBase = new YXBase("http://webscissor.appspot.com",3);
$(document).ready(function(){
	yxBase.GetUserID(
		function (){
			getid("span_username").innerHTML = yxBase.user_mail
				+' | <a href="http://webscissor.appspot.com/Logout?redi_url=' 
				+ chrome.extension.getURL("sync.htm") 
				+ '">退出</a>';
            ShowList();
		},
		function(){
			getid("span_username").innerHTML = '<a href="http://webscissor.appspot.com/Login?redi_url=' 
				+ chrome.extension.getURL("sync.htm") 
				+ '">登录</a>';
			//getid("span_update_status").innerHTML = '请登录后开始同步';
		}
	);
});
</script>
</head>
<body>
	<div id="debug"></div>
    <div id="main_container">
        <table width="90%" valign="top" align="center">
            <tr>
                <td align="left">
					<h1><img src="logo.png" width="30" />Web剪刀手</h1>
                </td>
                <td align="right">
                    <p>
                        <a href="./remember.htm">首页</a> | 
						<a href="./export.htm">导出</a> | 
						<a href="./import.htm">导入</a> | 
						<a href="http://code.google.com/p/webclip/" >Web剪刀手</a> |
                        <span id="span_username"><a href="http://webscissor.appspot.com/Login?redi_url=remember.htm" target="_blank">登录</a></span> 
                        
                    </p>
                </td>
            </tr>
        </table>
<table cellpadding="5" class="settings-table">
	<tr>
		<td valign="top" width="75%">
			<table width="100%">
				<tr>
					<td>
					</td>
					<td align="left">
						<div id="div_data"></div>
					</td>
					<td align="right">
					</td>
				</tr>
			</table>
			<div id="div_words">
			</div>
		</td>
		<!-- <td valign="top" width="15%">
			<div id="div_tags">
			</div> 
		</td>-->
	</tr>
</table>
</body>
</html>